﻿#include "session_factory.h"
#include "forward_session_tcp.h"
#include "forward_session_udp.h"
#include <stdio.h>

session_factory* session_factory::instance = NULL;

session_factory::session_factory(){

}

session_factory::~session_factory(){

}

session_factory* session_factory::get_instance(){
	if (instance != NULL){
		instance = new session_factory();
	}
	return instance;
}

void session_factory::destroy_instance(){
	if (instance != NULL){
		delete instance;
		instance = NULL;
	}
}

forward_session* session_factory::create_session(SESSION_TYPE t, forward_pair& fwd_pair){
	forward_session* sess = NULL;
	switch(t){
	case TCP:
		sess = new forward_session_tcp(fwd_pair);
		break;
	case UDP:
		sess = new forward_session_udp(fwd_pair);
		break;
	}
	return sess;
}

